
import org.apache.commons.beanutils.PropertyUtils;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.List;

@Service
public class UmsRolePermissionServiceImpl implements UmsRolePermissionService  {

    @Resource
    private UmsRolePermissionMapper umsRolePermissionMapper;

    /**
     * 获取 UmsRolePermission 分页列表
     */
    @Transactional
    public IPage getUmsRolePermissionPagination( PaginationVo paginationVo, UmsRolePermissionQuery umsRolePermissionQuery ) throws Exception {

        IPage page = new Page( paginationVo.getPageIndex(), paginationVo.getPageSize() );
        LambdaQueryWrapper<UmsRolePermissionEntity> lqs = new LambdaQueryWrapper();
        umsRolePermissionMapper.selectPage(page, lqs);

        List<UmsRolePermissionEntity> record = page.getRecords();
        if( !ObjectUtil.isNotEmptyList(record)){
            return page;
        }
        return null;
    }


    /**
     * 获取 UmsRolePermission 所有数据
     *
    */
    @Transactional
    public List<UmsRolePermissionEntity> getUmsRolePermissionAllList( UmsRolePermissionQuery umsRolePermissionQuery ) throws Exception {

        LambdaQueryWrapper<UmsRolePermissionEntity> lqs = new LambdaQueryWrapper();
        List<UmsRolePermissionEntity> list = umsRolePermissionMapper.selectList(lqs);
        return list;
    }


    /**
     * 获取 UmsRolePermission 详情
    */
    @Transactional
    public UmsRolePermissionEntity getUmsRolePermissionDetail( Long id) throws Exception {

        UmsRolePermissionEntity umsRolePermission = umsRolePermissionMapper.selectById(id);
        return umsRolePermission;
    }


    /**
     * 新增 UmsRolePermission
     * */
    @Transactional
    public void addUmsRolePermission(UmsRolePermissionVo umsRolePermissionVo) throws Exception {

        UmsRolePermissionEntity umsRolePermission = new UmsRolePermissionEntity();
        ReflectionCopy.copyProperties( umsRolePermission, umsRolePermissionVo );
        umsRolePermissionMapper.insert(umsRolePermission);
        return;
    }


    /**
     * 更新 UmsRolePermission
     * */
    @Transactional
    public void updateUmsRolePermission( UmsRolePermissionVo umsRolePermissionVo) throws Exception {

        if( umsRolePermissionVo.getId() == null ){
            throw GlobalException.gen(10021, "id不存在");
        }
        UmsRolePermissionEntity umsRolePermission = new UmsRolePermissionEntity();
        ReflectionCopy.copyProperties( umsRolePermission, umsRolePermissionVo );
        umsRolePermissionMapper.updateById(umsRolePermission);
        return;
    }

    /**
     * 删除 UmsRolePermission
     * */
    @Transactional
    public void batchRemoveUmsRolePermission( List<Long> ids ) throws Exception {


        if( !ObjectUtil.isNotEmptyList(ids) ){
            throw GlobalException.gen(10011, "要删除的id不存在");
        }
        umsRolePermissionMapper.deleteBatchIds(ids);
    }

}

      